package cn.shengongying.admin.config;

import org.sitemesh.config.ConfigurableSiteMeshFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;

/**
 * @author : RXK
 * Date : 2020-11-16 13:03
 * Code Less Think More
 * Desc:
 */
@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean<Filter> filterRegistrationBean() {
        FilterRegistrationBean<Filter> filterFilterRegistrationBean = new FilterRegistrationBean<>();
        filterFilterRegistrationBean.setFilter(configurableSiteMeshFilter());
        filterFilterRegistrationBean.addUrlPatterns("/*");
        return filterFilterRegistrationBean;
    }

    @Bean(destroyMethod = "destroy")
    public ConfigurableSiteMeshFilter configurableSiteMeshFilter() {
        return new ConfigurableSiteMeshFilter();
    }
}
